
function showItems(id){
    HttpRequest("showItems.jsp", "id=" + id, "fileTree");
    var projectNaam = $("#project_"+id).text();
    
    $('#tasksLink').css('display','block');
    $('#settingsLink').css('display','block');
    $('#pdfLink').css('display','block');
    
    $("#settingsLink").click(function(event){
        event.preventDefault();
        $('#projectPane').load('projects.jsp?sub=settings&pid='+id);
    });
    $("#tasksLink").click(function(event){
        event.preventDefault();
        $('#projectPane').load('projects.jsp?sub=tasks&pid='+id); 
    });
    $("#pdfLink").click(function(event){
        event.preventDefault();
        $('#projectPane').load('projects.jsp?sub=pdf&pid='+id);
        
    });
//    document.getElementById("tasksLink").onclick = "javascript:linkPage('tasks','"+id+"')";
//    document.getElementById("settingsLink").onclick = "javascript:linkPage('settings','"+id+"')";
    $("#Title").html("Projects > "+projectNaam);
}
function selectItem(id, project){
    HttpRequest("selectItem.jsp", "id=" + id + "&p=" + project, "fileInfo");
}
function download(p,i,v){
    var r = new XMLHttpRequest();
    r.open("POST", "download", true);
    r.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    r.send("p="+p+"&i="+i+"&r="+v);
}
function HttpRequest(file, parameters, target){
    var r = new XMLHttpRequest();
    r.onreadystatechange = function(){
        if(r.readyState == 4 && r.status == 200){
            document.getElementById(target).innerHTML = r.responseText;
        }
    }
    r.open("POST", file, true);
    r.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    r.send(parameters);
}
function load(file){
    HttpRequest(file, "", "content");
}

var pagina = "";

$(window).bind( 'hashchange', function(e) {
    
    if(self.document.location.hash.substring(1) == ""){
        pagina = "home.jsp";
    }
    else{
        pagina = self.document.location.hash.substring(1)+".jsp";
    }
    
    
    updatePagina(pagina);
});
// Functie die wordt aangeroepen als de pagina geladen is.
ready=function(){
    
    
    if(self.document.location.hash.substring(1) == ""){
        pagina = "home.jsp";
    }
    else{
        pagina = self.document.location.hash.substring(1)+".jsp";
    }
    
    
    updatePagina(pagina);
}

$("#home").click(function(){
    pagina = "home.jsp";
    updatePagina(pagina);
    
});

$("#profile").click(function(){
    pagina = "profile.jsp";
    updatePagina(pagina);
    
});

$("#projects").click(function(){
    pagina = "projects.jsp";
    updatePagina(pagina);
});

$("#admin").click(function(){
    pagina = "admin.jsp";
    updatePagina(pagina);
});



function updatePagina(pagina)
{
    $('#projectPane').load(pagina);
}


function hideChat()
{
    if($("#chat").width() > 0)
    {
        $("#hideChat").html("Show");
        $("#chat").animate({
            width:"0px"
        },500);
    
        $("#projectPane").animate({
            width:"100%"
        },500);
    }
    else
    {
        $("#hideChat").html("Hide");
        $("#chat").animate({
            width:"30%"
        },500);
    
        $("#projectPane").animate({
            width:"70%"
        },500);  
    }
}

